﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class StationOperate : IStationOperate
    {
        private HcDbContext _db { get; set; }
        public StationOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<Station> GetAllStationList()
        {

            return _db.Stations.ToList();
        }

        public Station GetStationById(string id)
        {
            return _db.Stations.SingleOrDefault(i => i.WorkStationId == id);
        }

        public List<Station> GetStationByIdList(List<string> ids)
        {
            return _db.Stations.Where(i => ids.Contains(i.WorkStationId)).ToList();
        }
        public List<Station> GetStationByPlcId(string plcId)
        {
            return _db.Stations.Where(i => i.PlcId == plcId).ToList();
        }
        public void AddStation(Station entity)
        {
            _db.Stations.Add(entity);
        }

        public void UpdateStation(Station entity)
        {
            _db.Stations.Update(entity);
        }

        public void DeleteStation(Station entity)
        {
            _db.Stations.Remove(entity);
        }

        public void BatchDelStation(List<Station> entity)
        {
            _db.Stations.RemoveRange(entity);

        }
    }
}
